package com.yzt.message.util;

import static com.yzt.message.MessageConstants.TYPE_ACCOUNT_PAY;
import static com.yzt.message.MessageConstants.TYPE_ACCOUNT_SYSTEM;
import static com.yzt.message.MessageConstants.TYPE_INTERACTIVE_MESSAGE;

import io.rong.imkit.conversationlist.model.BaseUiConversation;
import io.rong.imlib.model.Conversation;

/**
 * @author matthewzhao
 *         created on: 2022/7/19 18:18
 *         description: 一些消息过滤逻辑
 */
public class IMFilterUtil {

    public static boolean filterShowHeadView(BaseUiConversation uiConversation) {
        if (uiConversation.mCore.getPortraitUrl() != null) {
            String headUrl = uiConversation.mCore.getPortraitUrl();
            if (headUrl.contains("system/")) {
                return false; //是默认头像 ，返回 false  再 抢救一下
            }
        }
        //部分消息类型不弹
        switch (uiConversation.mCore.getSenderUserId()) {
            case TYPE_INTERACTIVE_MESSAGE:
            case TYPE_ACCOUNT_SYSTEM:
            case TYPE_ACCOUNT_PAY:
                return true;
        }
        if (uiConversation.mCore.getConversationType() != Conversation.ConversationType.PRIVATE) {
            return true;
        }
        if (uiConversation.mCore.getLatestMessage().getClass().getSimpleName().contains("RXAssistantMessageContent")) {
            return true;
        }

        return uiConversation.mCore.getLatestMessage().getClass().getSimpleName().contains("RXStarlightGiftContent");
    }
}
